/**
 *
 * \file shapes.cpp
 * \brief This file contains the shapes classes implementation.
 * \author Vladimir Klubkov (aka marked)
 *
 * Last changes date:
 * \date 15.03.2011
 *
 * Copyright 2011 Vladimir Klubkov <marked-one@yandex.ru>
 *
 * This file is part of OOXlib.
 *
 * OOXLib is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * OOXlib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OOXlib; if not, you can try to find  it here:
 * http://www.gnu.org/licenses/gpl.txt
 * or write to the Free Software Foundation, Inc., 59 Temple Place,
 * Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include "../include/shapes.h"

namespace OOXlib {

// CUInt2dPoint class implementation.
/**
 * Default constructor.
 */
CUInt2dPoint::CUInt2dPoint() : m_iX(0u), m_iY(0u) {}
/**
 * Constructor.
 * \param iX X-coordinate.
 * \param iY Y-coordinate.
 */
CUInt2dPoint::CUInt2dPoint(const unsigned int iX, const unsigned int iY) : m_iX(iX), m_iY(iY) {}
/**
 * Returns X-coordinate.
 * \return X-coordinate.
 */
unsigned int CUInt2dPoint::GetX() const {return m_iX;}
/**
 * Returns Y-coordinate.
 * \return Y-coordinate.
 */
unsigned int CUInt2dPoint::GetY() const {return m_iY;}
/**
 * Sets the new X-coordinate.
 * \param iX X-coordinate.
 */
void CUInt2dPoint::SetX(const unsigned int iX) {m_iX = iX;}
/**
 * Sets the new Y-coordinate.
 * \param iY Y-coordinate.
 */
void CUInt2dPoint::SetY(const unsigned int iY) {m_iY = iY;}
/**
 * Sets new coordinates.
 * \param iX X-coordinate.
 * \param iY Y-coordinate.
 */
void CUInt2dPoint::Set(const unsigned int iX, const unsigned int iY) {m_iX = iX;m_iY = iY;}
// CInt2dPoint class implementation.
/**
 * Default constructor.
 */
CInt2dPoint::CInt2dPoint() : m_iX(0), m_iY(0) {}
/**
 * Constructor.
 * \param iX X-coordinate.
 * \param iY Y-coordinate.
 */
CInt2dPoint::CInt2dPoint(const int iX, const int iY) : m_iX(iX), m_iY(iY) {}
/**
 * Returns X-coordinate.
 * \return X-coordinate.
 */
int CInt2dPoint::GetX() const {return m_iX;}
/**
 * Returns Y-coordinate.
 * \return Y-coordinate.
 */
int CInt2dPoint::GetY() const {return m_iY;}
/**
 * Sets the new X-coordinate.
 * \param iX X-coordinate.
 */
void CInt2dPoint::SetX(const int iX) {m_iX = iX;}
/**
 * Sets the new Y-coordinate.
 * \param iY Y-coordinate.
 */
void CInt2dPoint::SetY(const int iY) {m_iY = iY;}
/**
 * Sets new coordinates.
 * \param iX X-coordinate.
 * \param iY Y-coordinate.
 */
void CInt2dPoint::Set(const int iX, const int iY) {m_iX = iX;m_iY = iY;}
// CUInt2dLine class implementation.
/**
 * Default constructor.
 */
CUInt2dLine::CUInt2dLine() : m_iStartX(0u), m_iStartY(0u), m_iEndX(0u), m_iEndY(0u) {}
/**
 * Constructor.
 * \param iStartX Start point X-coordinate.
 * \param iStartY Start point Y-coordinate.
 * \param iEndX End point X-coordinate.
 * \param iEndY End point Y-coordinate.
 */
CUInt2dLine::CUInt2dLine(const unsigned int iStartX, const unsigned int iStartY, const unsigned int iEndX, const unsigned int iEndY)
: m_iStartX(iStartX), m_iStartY(iStartY), m_iEndX(iEndX), m_iEndY(iEndY) {}
/**
 * Constructor.
 * \param Start Start point coordinates.
 * \param End End point coordinates.
 */
CUInt2dLine::CUInt2dLine(const CUInt2dPoint &Start, const CUInt2dPoint &End)
: m_iStartX(Start.GetX()), m_iStartY(Start.GetY()), m_iEndX(End.GetX()), m_iEndY(End.GetY()) {}
/**
 * Returns the start point X-coordinate.
 * \return The start point X-coordinate.
 */
unsigned int CUInt2dLine::GetStartX() const {return m_iStartX;}
/**
 * Returns the start point Y-coordinate.
 * \return The start point Y-coordinate.
 */
unsigned int CUInt2dLine::GetStartY() const {return m_iStartY;}
/**
 * Returns the end point X-coordinate.
 * \return The end point X-coordinate.
 */
unsigned int CUInt2dLine::GetEndX() const {return m_iEndX;}
/**
 * Returns the end point Y-coordinate.
 * \return The end point Y-coordinate.
 */
unsigned int CUInt2dLine::GetEndY() const {return m_iEndY;}
/**
 * Returns the start point coordinates.
 * \return The start point coordinates.
 */
CUInt2dPoint CUInt2dLine::GetStart() const {return CUInt2dPoint(m_iStartX, m_iStartY);}
/**
 * Returns the end point coordinates.
 * \return The end point coordinates.
 */
CUInt2dPoint CUInt2dLine::GetEnd() const {return CUInt2dPoint(m_iEndX, m_iEndY);}
/**
 * Computes X and Y sizes of the line.
 * \return Sizes of the line.
 */
CUInt2dSize CUInt2dLine::GetSize() const {
    CUInt2dSize size;
    if(m_iStartX >= m_iEndX) {
        size.SetX(m_iStartX - m_iEndX);
    } else {
        size.SetX(m_iEndX - m_iStartX);
    }
    if(m_iStartY >= m_iEndY) {
        size.SetY(m_iStartY - m_iEndY);
    } else {
        size.SetY(m_iEndY - m_iStartY);
    }
    return size;
}
/**
 * Sets new start point X-coordinate.
 * \param iStartX Start point X-coordinate.
 */
void CUInt2dLine::SetStartX(const unsigned int iStartX) {m_iStartX = iStartX;}
/**
 * Sets new start point Y-coordinate.
 * \param iStartY Start point Y-coordinate.
 */
void CUInt2dLine::SetStartY(const unsigned int iStartY) {m_iStartY = iStartY;}
/**
 * Sets new end point X-coordinate.
 * \param iEndX End point X-coordinate.
 */
void CUInt2dLine::SetEndX(const unsigned int iEndX) {m_iEndX = iEndX;}
/**
 * Sets new end point Y-coordinate.
 * \param iEndY End point Y-coordinate.
 */
void CUInt2dLine::SetEndY(const unsigned int iEndY) {m_iEndY = iEndY;}
/**
 * Sets new start point coordinates.
 * \param iStartX Start point X-coordinate.
 * \param iStartY Start point Y-coordinate.
 */
void CUInt2dLine::SetStart(const unsigned int iStartX, const unsigned int iStartY) {m_iStartX = iStartX;m_iStartY = iStartY;}
/**
 * Sets new end point coordinates.
 * \param iEndX End point X-coordinate.
 * \param iEndY End point Y-coordinate.
 */
void CUInt2dLine::SetEnd(const unsigned int iEndX, const unsigned int iEndY) {m_iEndX = iEndX;m_iEndY = iEndY;}
/**
 * Sets new start point coordinates.
 * \param Start Start point coordinates.
 */
void CUInt2dLine::SetStart(const CUInt2dPoint &Start) {m_iStartX = Start.GetX(); m_iStartY = Start.GetY();}
/**
 * Sets new end point coordinates.
 * \param End End point coordinates.
 */
void CUInt2dLine::SetEnd(const CUInt2dPoint &End) {m_iEndX = End.GetX(); m_iEndY = End.GetY();}
/**
 * Sets new line coordinates.
 * \param iStartX Start point X-coordinate.
 * \param iStartY Start point Y-coordinate.
 * \param iEndX End point X-coordinate.
 * \param iEndY End point Y-coordinate.
 */
void CUInt2dLine::Set(const unsigned int iStartX, const unsigned int iStartY, const unsigned int iEndX, const unsigned int iEndY) {
    m_iStartX = iStartX; m_iStartY = iStartY; m_iEndX = iEndX; m_iEndY = iEndY;
}
/**
 * Sets new line coordinates.
 * \param Start Start point coordinates.
 * \param End End point coordinates.
 */
void CUInt2dLine::Set(const CUInt2dPoint &Start, const CUInt2dPoint &End) {
    m_iStartX = Start.GetX(); m_iStartY = Start.GetY(); m_iEndX = End.GetX(); m_iEndY = End.GetY();
}
// CInt2dLine class implementation.
/**
 * Default constructor.
 */
CInt2dLine::CInt2dLine() : m_iStartX(0), m_iStartY(0), m_iEndX(0), m_iEndY(0) {}
/**
 * Constructor.
 * \param iStartX Start point X-coordinate.
 * \param iStartY Start point Y-coordinate.
 * \param iEndX End point X-coordinate.
 * \param iEndY End point Y-coordinate.
 */
CInt2dLine::CInt2dLine(const int iStartX, const int iStartY, const int iEndX, const int iEndY)
: m_iStartX(iStartX), m_iStartY(iStartY), m_iEndX(iEndX), m_iEndY(iEndY) {}
/**
 * Constructor.
 * \param Start Start point coordinates.
 * \param End End point coordinates.
 */
CInt2dLine::CInt2dLine(const CInt2dPoint &Start, const CInt2dPoint &End)
: m_iStartX(Start.GetX()), m_iStartY(Start.GetY()), m_iEndX(End.GetX()), m_iEndY(End.GetY()) {}
/**
 * Returns the start point X-coordinate.
 * \return The start point X-coordinate.
 */
int CInt2dLine::GetStartX() const {return m_iStartX;}
/**
 * Returns the start point Y-coordinate.
 * \return The start point Y-coordinate.
 */
int CInt2dLine::GetStartY() const {return m_iStartY;}
/**
 * Returns the end point X-coordinate.
 * \return The end point X-coordinate.
 */
int CInt2dLine::GetEndX() const {return m_iEndX;}
/**
 * Returns the end point Y-coordinate.
 * \return The end point Y-coordinate.
 */
int CInt2dLine::GetEndY() const {return m_iEndY;}
/**
 * Returns the start point coordinates.
 * \return The start point coordinates.
 */
CInt2dPoint CInt2dLine::GetStart() const {return CInt2dPoint(m_iStartX, m_iStartY);}
/**
 * Returns the end point coordinates.
 * \return The end point coordinates.
 */
CInt2dPoint CInt2dLine::GetEnd() const {return CInt2dPoint(m_iEndX, m_iEndY);}
/**
 * Computes X and Y sizes of the line.
 * \return Sizes of the line.
 */
CInt2dSize CInt2dLine::GetSize() const {
    CInt2dSize size;
    if(m_iStartX >= m_iEndX) {
        size.SetX(m_iStartX - m_iEndX);
    } else {
        size.SetX(m_iEndX - m_iStartX);
    }
    if(m_iStartY >= m_iEndY) {
        size.SetY(m_iStartY - m_iEndY);
    } else {
        size.SetY(m_iEndY - m_iStartY);
    }
    return size;
}
/**
 * Sets new start point X-coordinate.
 * \param iStartX Start point X-coordinate.
 */
void CInt2dLine::SetStartX(const int iStartX) {m_iStartX = iStartX;}
/**
 * Sets new start point Y-coordinate.
 * \param iStartY Start point Y-coordinate.
 */
void CInt2dLine::SetStartY(const int iStartY) {m_iStartY = iStartY;}
/**
 * Sets new end point X-coordinate.
 * \param iEndX End point X-coordinate.
 */
void CInt2dLine::SetEndX(const int iEndX) {m_iEndX = iEndX;}
/**
 * Sets new end point Y-coordinate.
 * \param iEndY End point Y-coordinate.
 */
void CInt2dLine::SetEndY(const int iEndY) {m_iEndY = iEndY;}
/**
 * Sets new start point coordinates.
 * \param iStartX Start point X-coordinate.
 * \param iStartY Start point Y-coordinate.
 */
void CInt2dLine::SetStart(const int iStartX, const int iStartY) {m_iStartX = iStartX;m_iStartY = iStartY;}
/**
 * Sets new end point coordinates.
 * \param iEndX End point X-coordinate.
 * \param iEndY End point Y-coordinate.
 */
void CInt2dLine::SetEnd(const int iEndX, const int iEndY) {m_iEndX = iEndX;m_iEndY = iEndY;}
/**
 * Sets new start point coordinates.
 * \param Start Start point coordinates.
 */
void CInt2dLine::SetStart(const CInt2dPoint &Start) {m_iStartX = Start.GetX(); m_iStartY = Start.GetY();}
/**
 * Sets new end point coordinates.
 * \param End End point coordinates.
 */
void CInt2dLine::SetEnd(const CInt2dPoint &End) {m_iEndX = End.GetX(); m_iEndY = End.GetY();}
/**
 * Sets new line coordinates.
 * \param iStartX Start point X-coordinate.
 * \param iStartY Start point Y-coordinate.
 * \param iEndX End point X-coordinate.
 * \param iEndY End point Y-coordinate.
 */
void CInt2dLine::Set(const int iStartX, const int iStartY, const int iEndX, const int iEndY) {
    m_iStartX = iStartX; m_iStartY = iStartY; m_iEndX = iEndX; m_iEndY = iEndY;
}
/**
 * Sets new line coordinates.
 * \param Start Start point coordinates.
 * \param End End point coordinates.
 */
void CInt2dLine::Set(const CInt2dPoint &Start, const CInt2dPoint &End) {
    m_iStartX = Start.GetX(); m_iStartY = Start.GetY(); m_iEndX = End.GetX(); m_iEndY = End.GetY();
}
// CUInt2dRectangle class implementation.
/**
 * Default constructor.
 */
CUInt2dRectangle::CUInt2dRectangle() : m_iX(0u), m_iY(0u), m_iWidth(0u), m_iHeight(0u) {}
/**
 * Constructor.
 * \param iX X-Position of the left top corner.
 * \param iY Y-Position of the left top corner.
 * \param iWidth Width of the rectangle.
 * \param iHeight Height of the rectangle.
 */
CUInt2dRectangle::CUInt2dRectangle(const unsigned int iX, const unsigned int iY, const unsigned int iWidth, const unsigned int iHeight)
:  m_iX(iX), m_iY(iY), m_iWidth(iWidth), m_iHeight(iHeight) {}
/**
 * Constructor.
 * \param Position Position of the left top corner.
 * \param Size Width and height of the rectangle.
 */
CUInt2dRectangle::CUInt2dRectangle(const CUInt2dPoint &Position, const CUInt2dSize &Size)
: m_iX(Position.GetX()), m_iY(Position.GetY()), m_iWidth(Size.GetX()), m_iHeight(Size.GetY()) {}
/**
 * Returns the X-Position of the rectangle.
 * \return Rectangle X-Position coordinate.
 */
unsigned int CUInt2dRectangle::GetPositionX() const {return m_iX;}
/**
 * Returns the Y-Position of the rectangle.
 * \return Rectangle Y-Position coordinate.
 */
unsigned int CUInt2dRectangle::GetPositionY() const {return m_iY;}
/**
 * Returns the rectangle width.
 * \return Rectangle width.
 */
unsigned int CUInt2dRectangle::GetWidth() const {return m_iWidth;}
/**
 * Returns the rectangle height.
 * \return Rectangle height.
 */
unsigned int CUInt2dRectangle::GetHeight() const {return m_iHeight;}
/**
 * Returns the rectangle position.
 * \return Rectangle position coordinates.
 */
CUInt2dPoint CUInt2dRectangle::GetPosition() const {return CUInt2dPoint(m_iX, m_iY);}
/**
 * Returns the rectangle size.
 * \return Rectangle width and height.
 */
CUInt2dSize CUInt2dRectangle::GetSize() const {return CUInt2dSize(m_iWidth, m_iHeight);}
/**
 * Sets new rectangle X-Position.
 * \param iX X-Position of the left top corner.
 */
void CUInt2dRectangle::SetPositionX(const unsigned int iX) {m_iX = iX;}
/**
 * Sets new rectangle Y-Position.
 * \param iY Y-Position of the left top corner.
 */
void CUInt2dRectangle::SetPositionY(const unsigned int iY) {m_iY = iY;}
/**
 * Sets new rectangle width.
 * \param iWidth Width of the rectangle.
 */
void CUInt2dRectangle::SetWidth(const unsigned int iWidth) {m_iWidth = iWidth;}
/**
 * Sets new rectangle height.
 * \param iHeight Height of the rectangle.
 */
void CUInt2dRectangle::SetHeight(const unsigned int iHeight) {m_iHeight = iHeight;}
/**
 * Sets new rectangle position.
 * \param iX X-Position of the left top corner.
 * \param iY Y-Position of the left top corner.
 */
void CUInt2dRectangle::SetPosition(const unsigned int iX, const unsigned int iY) {m_iX = iX; m_iY = iY;}
/**
 * Sets new rectangle size.
 * \param iWidth Width of the rectangle.
 * \param iHeight Height of the rectangle.
 */
void CUInt2dRectangle::SetSize(const unsigned int iWidth, const unsigned int iHeight) {m_iWidth = iWidth; m_iHeight = iHeight;}
/**
 * Sets new rectangle position.
 * \param Position Position of the left top corner.
 */
void CUInt2dRectangle::SetPosition(const CUInt2dPoint &Position) {m_iX = Position.GetX(); m_iY = Position.GetY();}
/**
 * Sets new rectangle size.
 * \param Size Width and height of the rectangle.
 */
void CUInt2dRectangle::SetSize(const CUInt2dPoint &Size) {m_iWidth = Size.GetX(); m_iHeight = Size.GetY();}
/**
 * Sets new rectangle.
 * \param iX X-Position of the left top corner.
 * \param iY Y-Position of the left top corner.
 * \param iWidth Width of the rectangle.
 * \param iHeight Height of the rectangle.
 */
void CUInt2dRectangle::Set(const unsigned int iX, const unsigned int iY, const unsigned int iWidth, const unsigned int iHeight) {
    m_iX = iX; m_iY = iY; m_iWidth = iWidth; m_iHeight = iHeight;
}
/**
 * Sets new rectangle.
 * \param Position Position of the left top corner.
 * \param Size Width and height of the rectangle.
 */
void CUInt2dRectangle::Set(const CUInt2dPoint &Position, const CUInt2dSize &Size) {
    m_iX = Position.GetX(); m_iY = Position.GetY(); m_iWidth = Size.GetX(); m_iHeight = Size.GetY();
}
// CInt2dRectangle class implementation.
/**
 * Default constructor.
 */
CInt2dRectangle::CInt2dRectangle() : m_iX(0), m_iY(0), m_iWidth(0), m_iHeight(0) {}
/**
 * Constructor.
 * \param iX X-Position of the left top corner.
 * \param iY Y-Position of the left top corner.
 * \param iWidth Width of the rectangle.
 * \param iHeight Height of the rectangle.
 */
CInt2dRectangle::CInt2dRectangle(const int iX, const int iY, const int iWidth, const int iHeight)
:  m_iX(iX), m_iY(iY), m_iWidth(iWidth), m_iHeight(iHeight) {}
/**
 * Constructor.
 * \param Position Position of the left top corner.
 * \param Size Width and height of the rectangle.
 */
CInt2dRectangle::CInt2dRectangle(const CInt2dPoint &Position, const CInt2dSize &Size)
: m_iX(Position.GetX()), m_iY(Position.GetY()), m_iWidth(Size.GetX()), m_iHeight(Size.GetY()) {}
/**
 * Returns the X-Position of the rectangle.
 * \return Rectangle X-Position coordinate.
 */
int CInt2dRectangle::GetPositionX() const {return m_iX;}
/**
 * Returns the Y-Position of the rectangle.
 * \return Rectangle Y-Position coordinate.
 */
int CInt2dRectangle::GetPositionY() const {return m_iY;}
/**
 * Returns the rectangle width.
 * \return Rectangle width.
 */
int CInt2dRectangle::GetWidth() const {return m_iWidth;}
/**
 * Returns the rectangle height.
 * \return Rectangle height.
 */
int CInt2dRectangle::GetHeight() const {return m_iHeight;}
/**
 * Returns the rectangle position.
 * \return Rectangle position coordinates.
 */
CInt2dPoint CInt2dRectangle::GetPosition() const {return CInt2dPoint(m_iX, m_iY);}
/**
 * Returns the rectangle size.
 * \return Rectangle width and height.
 */
CInt2dSize CInt2dRectangle::GetSize() const {return CInt2dSize(m_iWidth, m_iHeight);}
/**
 * Sets new rectangle X-Position.
 * \param iX X-Position of the left top corner.
 */
void CInt2dRectangle::SetPositionX(const int iX) {m_iX = iX;}
/**
 * Sets new rectangle Y-Position.
 * \param iY Y-Position of the left top corner.
 */
void CInt2dRectangle::SetPositionY(const int iY) {m_iY = iY;}
/**
 * Sets new rectangle width.
 * \param iWidth Width of the rectangle.
 */
void CInt2dRectangle::SetWidth(const int iWidth) {m_iWidth = iWidth;}
/**
 * Sets new rectangle height.
 * \param iHeight Height of the rectangle.
 */
void CInt2dRectangle::SetHeight(const int iHeight) {m_iHeight = iHeight;}
/**
 * Sets new rectangle position.
 * \param iX X-Position of the left top corner.
 * \param iY Y-Position of the left top corner.
 */
void CInt2dRectangle::SetPosition(const int iX, const int iY) {m_iX = iX; m_iY = iY;}
/**
 * Sets new rectangle size.
 * \param iWidth Width of the rectangle.
 * \param iHeight Height of the rectangle.
 */
void CInt2dRectangle::SetSize(const int iWidth, const int iHeight) {m_iWidth = iWidth; m_iHeight = iHeight;}
/**
 * Sets new rectangle position.
 * \param Position Position of the left top corner.
 */
void CInt2dRectangle::SetPosition(const CInt2dPoint &Position) {m_iX = Position.GetX(); m_iY = Position.GetY();}
/**
 * Sets new rectangle size.
 * \param Size Width and height of the rectangle.
 */
void CInt2dRectangle::SetSize(const CInt2dPoint &Size) {m_iWidth = Size.GetX(); m_iHeight = Size.GetY();}
/**
 * Sets new rectangle.
 * \param iX X-Position of the left top corner.
 * \param iY Y-Position of the left top corner.
 * \param iWidth Width of the rectangle.
 * \param iHeight Height of the rectangle.
 */
void CInt2dRectangle::Set(const int iX, const int iY, const int iWidth, const int iHeight) {
    m_iX = iX; m_iY = iY; m_iWidth = iWidth; m_iHeight = iHeight;
}
/**
 * Sets new rectangle.
 * \param Position Position of the left top corner.
 * \param Size Width and height of the rectangle.
 */
void CInt2dRectangle::Set(const CInt2dPoint &Position, const CInt2dSize &Size) {
    m_iX = Position.GetX(); m_iY = Position.GetY(); m_iWidth = Size.GetX(); m_iHeight = Size.GetY();
}

} // OOXlib
